﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace canyinguanlixitong
{
    public partial class frmaddroom : Form
    {
        public frmaddroom()
        {
            InitializeComponent();
        }
        //tbxroomstyle，tbxzuidi，tbxrongna
        string strconn = "Data Source=.;Initial Catalog=Supermarket management system;Integrated Security=True";
        private void frmaddroom_Load(object sender, EventArgs e)
        {

        }
             public void add() {
            SqlConnection conn = new SqlConnection(strconn);
            conn.Open();
            int bianhao =Convert.ToInt32(this.tbxrongna.Text);
            string name = this.tbxroomstyle.Text;
            string sex = this.tbxzuidi.Text;

            string sql = @"insert into [Room type](fangName,fangJia,fangID)
                values('"+name+"','"+sex+"','"+bianhao+"')";
            SqlCommand cmd = new SqlCommand(sql,conn);
            int result = cmd.ExecuteNonQuery();
            if (result == 1)
            { 
                MessageBox.Show("新增成功");
            }
            else {
                MessageBox.Show("新增失败");
            }

            conn.Close();
        }

             private void button1_Click(object sender, EventArgs e)
             {
                 add();
             }
    }
    }

